package com.feicheng.lanniao.service.impl;

import com.feicheng.lanniao.entity.PayCost;
import com.feicheng.lanniao.exception.SystemException;

import com.feicheng.lanniao.mapper.PayCostMapper;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.IPayCostService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-02
 */
@Service
public class PayCostServiceImpl extends ServiceImpl<PayCostMapper, PayCost> implements IPayCostService {

	/**
	 * @see PayCostServiceImpl.getList
	 */
	@Override
	public ResultInfo getList() {
		
		return ResultInfo.success(this.list());
	}

	/**
	 * @see PayCostServiceImpl.updateOne
	 */
	@Override
	public ResultInfo getOne(Integer orderTypeId) {
		
		return ResultInfo.success(this.getById(orderTypeId));
	}

	/**
	 * @see PayCostServiceImpl.updateOne
	 */
	@Override
	public ResultInfo updateOne(PayCost payCost) {
		if (null == payCost.getOrderTypeId()) {
			throw new SystemException("订单类型价格id缺失，无法更新");
		}
		if (null == payCost.getPrice()) {
			throw new SystemException("订单类型价格缺失，无法更新");
		}
		this.updateById(payCost);
		return ResultInfo.success();
	}

}
